package com.seaengine.util
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.geom.Matrix;
	
	/**
	 * 显示对象拷贝
	 * @author 曹鹏
	 */	
	public class DisplayObjectCopy
	{
	
		//--------------------------------------------------------------------------
		//
		//  variable
		//
		//--------------------------------------------------------------------------
		
		public function DisplayObjectCopy()
		{
			
		}
	
		//--------------------------------------------------------------------------
		//
		//  public
		//
		//--------------------------------------------------------------------------
		/**
		 * 开始拷贝
		 * @param targetObj目标对象
		 * @param matrix  转换矩阵(用于偏移)
		 */		
		public static function copy(targetObj:DisplayObject,matrix:Matrix=null):Bitmap
		{
			var bitmapData:BitmapData = new BitmapData(targetObj.width,targetObj.height,true,0);
			bitmapData.draw(targetObj,matrix);
			var bitmap:Bitmap = new Bitmap(bitmapData);
			
			bitmapData = null;
			matrix = null;
			return bitmap;
		}
	}
}